package com.bsdk.install.device.lockLora.v1.cmd;

/**
 * @ProjectName: com.hlslock.utils.lock
 * @Package: com.hlslock.utils.lock
 * @ClassName: ICmd
 * @Author: HansYoung
 * @Description: cmd
 * @Createtime: 2023/12/11 08:40
 * @Modifytime: 2023/12/14 20:44
 * @Version: 1.0
 * @Copyright: ©2006-2023 版权所有. 深圳豪力士
 */
public interface ICmd {
    public static final String VERSION = "V1.0.0";
    // 锁的命令
    public static final byte CMD_REMOTE_UNLOCK_REQ = (byte) 0x30;// 远程开锁
    public static final byte CMD_REMOTE_LOCK_REQ = (byte) 0x31;// 远程关锁
    public static final byte CMD_REMOTE_RESET_REQ = (byte) 0x32;// 远程复位
    public static final byte CMD_ADDPASS_BY_ID_REQ = (byte) 0x3E;// 添加修改密码用户 0X3E

    public static final byte CMD_ADDCARD_BY_ID_REQ = (byte) 0x3F;// 添加修改卡用户 0X3F

    public static final byte CMD_ADDFINGER_BY_ID_REQ = (byte) 0x40;// 添加修改指纹用户 0X40
    public static final byte CMD_DIS_ENABLE_BY_ID_REQ = (byte) 0x3C;// 通过用户编号冻结、解冻用户 0x3c
    public static final byte CMD_ADD_ADMIN_PASSWORD_REQ = (byte) 0x3D;// 下发临时密码key 0x3d
    public static final byte CMD_DELPASS_BY_ID_REQ = (byte) 0x38;// 通过ID删除用户　　0x38
    public static final byte CMD_MODIPASS_BY_ID_REQ = (byte) 0x42;// 通过ID修改密码    0x42
    public static final byte CMD_MODIVALID_BY_ID_REQ = (byte) 0x41;// 通过ID修改有效期　　0x41
    public static final byte CMD_ADJUST_TIME_REQ = (byte) 0x3A;// 下发校准时间  0x3A

//////////以下与锁的程序一致
    public static final byte TYPE_SERVER_LOCK_REQ = (byte) 0x80; //服务器发给锁的请求
    public static final byte TYPE_SERVER_LOCK_ACK = (byte) 0x86; //锁应答服务器的响应
    public static final byte CMD_REMOTE_UNLOCK_DOW = (byte) 0x30; //下发远程开锁
    public static final byte CMD_REMOTE_LOCK_DOW = (byte) 0x31; //下发远程关锁
    public static final byte CMD_LOCK_SYS_INIT = (byte) 0x32; //门锁初始化
    public static final byte CMD_ADD_PASSWD_USER = (byte) 0x33; //添加密码
    public static final byte CMD_ADD_CARD_USER = (byte) 0x34; //添加卡
    public static final byte CMD_ADD_FINGER_USER = (byte) 0x35; //添加指纹
    public static final byte CMD_DOWN_FINGER_DATA = (byte) 0x36; //下载指纹数据
    public static final byte CMD_FINGER_ARQ_ID = (byte) 0x37; //获取指纹重传ID
    public static final byte CMD_DELETE_BY_ID = (byte) 0x38; //通过用户ID删除
    public static final byte CMD_DELETE_BY_PASSWD = (byte) 0x39; //通过用户密码删除
    public static final byte CMD_REMOTE_TIMER_SET_OPT = (byte) 0x3A; //服务器设置时间
    public static final byte CMD_CLEAR_FINGER_DATA = (byte) 0x3B; //清除指纹数据
    public static final byte CMD_FREEZE_UNFREEZE_USER = (byte) 0x3C; //冻结解冻用户
    public static final byte CMD_MODIFY_SUPER_PASSWD = (byte) 0x3D; //修改超级密码
    public static final byte CMD_ADD_MODIFY_PASSWD_USER = (byte) 0x3E; //添加或修改密码
    public static final byte CMD_ADD_MODIFY_CARD_USER = (byte) 0x3F; //添加或修改卡
    public static final byte CMD_ADD_MODIFY_FINGER_USER = (byte) 0x40; //添加或修改指纹
    public static final byte CMD_MODIFY_PERODIC_BY_ID = (byte) 0x41; //通过用户ID修改有效期
    public static final byte CMD_MODIFY_PASSWD_BY_ID = (byte) 0x42; //通过用户ID修改密码

    public static final byte CMD_ADD_FACE_USER = (byte) 0x43; //添加人脸用户

    public static final byte TYPE_SERVER_LOCK_MSG = (byte) 0x8F; //服务器发给锁的消息
    public static final byte CMD_DOWN_FINGER_DATA_NO_ACK = (byte) 0x30; //下载指纹数据
    public static final byte CMD_REMOTE_ONE_VOICE_PLAY = (byte) 0x31; //服务器播报一条语音
    public static final byte CMD_SERVER_NOTIFY_DOWNLOAD = (byte) 0x32; //服务器通知锁进入升级模式

    public static final byte TYPE_LOCK_SERVER_REQ = (byte) 0x70; //锁发给服务器的请求
    public static final byte TYPE_LOCK_SERVER_ACK = (byte) 0x76; //服务器应答锁的响应
    public static final byte TYPE_LOCK_SERVER_MSG = (byte) 0x7F; //锁发给服务器的消息
    public static final byte CMD_BELL_KEY = (byte) 0x30; //门铃键报告
    public static final byte CMD_REMOTE_UNLOCK_UP = (byte) 0x31; //本地请求远程开锁
    public static final byte CMD_USER_UNLOCK_UP = (byte) 0x32; //开锁上报
    public static final byte CMD_USER_LOCK_UP = (byte) 0x33; //关锁上报
    public static final byte CMD_ADD_PASSWD_USR_UP = (byte) 0x34; //添加密码上报
    public static final byte CMD_DEL_PASSWD_USR_UP = (byte) 0x35; //删除密码上报
    public static final byte CMD_ADD_CARD_USR_UP = (byte) 0x36; //添加卡上报
    public static final byte CMD_DEL_CARD_USR_UP = (byte) 0x37; //删除卡上报
    public static final byte CMD_ADD_FINGER_USR_UP = (byte) 0x38; //添加指纹上报
    public static final byte CMD_DEL_FINGER_USR_UP = (byte) 0x39; //删除指纹上报
    public static final byte CMD_ADD_FACE_USR_UP = (byte) 0x3A; //添加人脸上报
    public static final byte CMD_DEL_FACE_USR_UP = (byte) 0x3B; //删除人脸上报
    public static final byte CMD_PASSWD_UNLOCK_FREEZE_UP = (byte) 0x3C; //密码开锁被冻结上报
    public static final byte CMD_CARD_UNLOCK_FREEZE_UP = (byte) 0x3D; //卡片开锁被冻结上报
    public static final byte CMD_FINGER_UNLOCK_FREEZE_UP = (byte) 0x3E; //指纹开锁被冻结上报
    public static final byte CMD_FACE_UNLOCK_FREEZE_UP = (byte) 0x3F; //人脸开锁被冻结上报
    public static final byte CMD_PASSWD_ATK_UP = (byte) 0x40; //密码攻击
    public static final byte CMD_CARD_ATK_UP = (byte) 0x41; //卡片攻击
    public static final byte CMD_FINGER_ATK_UP = (byte) 0x42; //指纹攻击
    public static final byte CMD_FACE_ATK_UP = (byte) 0x43; //人脸攻击
    public static final byte CMD_PASSWD_ANY_ATK_UP = (byte) 0x44; //密码多次验证失败上报
    public static final byte CMD_CARD_ANY_ATK_UP = (byte) 0x45; //卡片多次验证失败上报
    public static final byte CMD_FINGER_ANY_ATK_UP = (byte) 0x46; //指纹多次验证失败上报
    public static final byte CMD_FACE_ANY_ATK_UP = (byte) 0x47; //人脸多次验证失败上报
    public static final byte CMD_PRIED_LOCK_UP = (byte) 0x48; //防撬报警
    public static final byte CMD_LOW_BATTERY_UP = (byte) 0x49; //低电报警
    public static final byte CMD_HIJACK_USER_UP = (byte) 0x4A; //劫持报警
    public static final byte CMD_SYS_LOCKIN_UP = (byte) 0x4B; //系统锁定报警
    public static final byte CMD_SYS_INIT_UP = (byte) 0x4C; //系统初始化上报
    public static final byte CMD_ENABLE_NORMALLY_UP = (byte) 0x4D; //常开模式已开启上报
    public static final byte CMD_DISABLE_NORMALLY_UP = (byte) 0x4E; //常开模式已关闭上报
    public static final byte CMD_INSIDE_KEY_LOCK_UP = (byte) 0x4F; //门内按键关锁上报
    public static final byte CMD_INSIDE_KEY_UNLOCK_UP = (byte) 0x50; //门内按键开锁上报
    public static final byte CMD_STAY_REMIND_UP = (byte) 0x51; //有人逗留
    public static final byte CMD_DOOR_UNCLOSE_UP = (byte) 0x52; //门没关好
    public static final byte CMD_INSIDE_LOCK_UP = (byte) 0x53; //门已反锁上报
    public static final byte CMD_INSIDE_UNLOCK_UP = (byte) 0x54; //门已解锁上报
    public static final byte CMD_BATTERY_VOLTAGE_UP = (byte) 0x55; //电量上报
    public static final byte CMD_DEL_ALL_USR_UP = (byte) 0x56; //删除所有用户上报

    public static final byte TYPE_SERVER_DEVICE_REQ = (byte) 0x60; //服务器发给模块的请求
    public static final byte TYPE_SERVER_DEVICE_ACK = (byte) 0x66; //模块应答服务器的响应
    public static final byte TYPE_SERVER_DEVICE_MSG = (byte) 0x6F; //服务器发给模块的消息

    public static final byte TYPE_DEVICE_SERVER_REQ = (byte) 0x50; //模块发给服务器的请求
    public static final byte TYPE_DEVICE_SERVER_ACK = (byte) 0x56; //服务器应答模块的响应
    public static final byte TYPE_DEVICE_SERVER_MSG = (byte) 0x5F; //模块发给服务器的消息
    public static final byte CMD_HEART_BEAT_PKG = (byte) 0x30; //模块心跳包
    public static final byte CMD_DEVICE_REGISTER = (byte) 0x31; //设备注册或注销

    public static final byte TYPE_DEVICE_LOCK_REQ = (byte) 0x40; //模块发给锁的请求
    public static final byte TYPE_DEVICE_LOCK_ACK = (byte) 0x46; //锁应答模块的响应
    public static final byte CMD_DEV_SEND_UPGRADE_PKG = (byte) 0x30; //模块发送升级包
    public static final byte CMD_DEV_SEND_UPGRADE_START = (byte) 0x31; //模块通知锁开始升级

    public static final byte TYPE_DEVICE_LOCK_MSG = (byte) 0x4F; //模块发给锁的消息
    public static final byte CMD_RESET_KEY_OPT = (byte) 0x30; //复位按键操作 0抬起 1按下 2成功
    public static final byte CMD_TIMER_SET_OPT = (byte) 0x31; //设置时间
    public static final byte CMD_DEV_ONE_VOICE_PLAY = (byte) 0x32; //模块播报一条语音
    public static final byte CMD_DEV_BATTERY_VOLTAGE = (byte) 0x33; //模块让锁上报电量
    public static final byte CMD_DEV_NOTIFY_DOWNLOAD = (byte) 0x34; //模块通知锁进入升级模式

    public static final byte TYPE_LOCK_DEVICE_REQ = (byte) 0x30; //锁发给模块的请求
    public static final byte TYPE_LOCK_DEVICE_ACK = (byte) 0x36; //模块应答锁的响应
    public static final byte CMD_SEND_NB_IMEI = (byte) 0x30; //IMEI
    public static final byte CMD_SEND_NB_IMSI = (byte) 0x31; //IMSI
    public static final byte CMD_SEND_NB_NCCID = (byte) 0x32; //NCCID
    public static final byte CMD_DEVICE_APP_VERSION = (byte) 0x33; //模块app版本
    public static final byte CMD_DEVICE_BOOT_VERSION = (byte) 0x34; //模块boot版本
    public static final byte CMD_RF_ENABLE_STATE = (byte) 0x35; //无线开或关
    public static final byte CMD_SEND_NB_CSQ = (byte) 0x36; //CSQ

    public static final byte TYPE_LOCK_DEVICE_MSG = (byte) 0x3F; //锁发给模块的消息
    public static final byte CMD_ACTIVE_LOGIN_KEY = (byte) 0x30; //模块主动登录
    public static final byte CMD_PRESS_STAR_KEY = (byte) 0x31; //发送*键
    public static final byte CMD_ENABLE_BLE = (byte) 0x32; //打开蓝牙
    public static final byte CMD_SET_CHN_ENG_SWITCH = (byte) 0x33; //语言切换
    public static final byte CMD_SET_UNLOCK_KEEPTIME = (byte) 0x36; //关锁保持时间
    public static final byte CMD_SET_AUTOLOCK = (byte) 0x37; //自动关锁
    public static final byte CMD_SET_DOUBLEAUTH = (byte) 0x38; //双重认证
    public static final byte CMD_SET_FANGQIAO = (byte) 0x39; //防撬开关
    public static final byte CMD_SET_DISTANCE = (byte) 0x3A; //人体感应
    public static final byte CMD_SET_VOLUE_LEVEL = (byte) 0x3B; //音量调节
    public static final byte CMD_SET_AGING_MODE = (byte) 0x3E; //老化模式

    //以下是网关的注册
    public static final byte  CHILD_SET_MASTER_ADDR_CMD = (byte) 0x7E; //注册模块
    public static final byte  CHILD_REQ_MASTER_ADDR_CMD = (byte) 0x7F; //查询模块注册

    /**
     * 构建密码
     *
     * @param pw       密码
     * @param pwMaxLen 密码最大长度
     * @return
     */
    public String buildPassword(String pw, int pwMaxLen);

    public int buildUserId(int userId, byte[] data, int dataStart);

    public int buildTime(String time, byte[] data, int dataStart);

    public String buildTimeString(byte[] buf,int dataStart);
    /**
     * 字符串转字节
     *
     * @param s
     * @return
     */
    byte[] toBytes(String s);

    byte[] Valid_toBytes(String s,byte type);
    /**
     * 命令校验
     *
     * @param byteData
     * @param len
     * @return
     */
    byte check(byte[] byteData, int len);

    /**
     * 网关协议
     * @param byteData
     * @param len
     * @return
     */
    byte check_crc(byte[] ptr, int n);
}